﻿using GalaSoft.MvvmLight.Messaging;
using System.Windows;
using System.Windows.Controls;

namespace TransControlSystem.View
{
    /// <summary>
    /// ControlModeSwitchingWindow.xaml 的交互逻辑
    /// </summary>
    public partial class ControlModeSwitchingWindow : Window
    {
        public ControlModeSwitchingWindow()
        {
            InitializeComponent();
            Messenger.Default.Register<NotificationMessage>(this, (nm) =>
            {
                if (nm.Notification == "CloseWindowsBoundToHideControlModeSwitchingWindow")
                {
                    if (nm.Sender == DataContext)
                        Hide();
                }
            });
        }
        private void dg_taskList_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
        {
            if (e.Column.Header.ToString() == "Id" ||
                     e.Column.Header.ToString() == "Priority" ||
                     e.Column.Header.ToString() == "PriorityNo" ||
                     e.Column.Header.ToString() == "EquipmentName" ||
                     e.Column.Header.ToString() == "PriorityArrangementNumber" ||
                     e.Column.Header.ToString() == "OrderNo" ||
                     e.Column.Header.ToString() == "TagDesc" ||
                     e.Column.Header.ToString() == "Address" ||
                     e.Column.Header.ToString() == "ValueType" ||
                     e.Column.Header.ToString() == "Value" ||
                     e.Column.Header.ToString() == "ReadOrWrite" ||
                     e.Column.Header.ToString() == "Remark" ||
                     e.Column.Header.ToString() == "IsEnable" ||
                     e.Column.Header.ToString() == "Type" ||
                     e.Column.Header.ToString() == "IsTheTaskInProgress" ||
                     e.Column.Header.ToString() == "IsTheTaskNotPerformed" ||
                     e.Column.Header.ToString() == "FirstTriggersBuildTaskTagDesc" ||
                     e.Column.Header.ToString() == "FirstTriggersBuildTaskAddress" ||
                     e.Column.Header.ToString() == "FirstTriggersBuildTaskValueType" ||
                     e.Column.Header.ToString() == "FirstTriggersBuildTaskValue" ||
                     e.Column.Header.ToString() == "FirstTriggersBuildTaskPoint" ||
                     e.Column.Header.ToString() == "FirstTriggersBuildTaskValue" ||
                     e.Column.Header.ToString() == "SecondaryTriggersBuildTaskTagDesc" ||
                     e.Column.Header.ToString() == "SecondaryTriggersBuildTaskAddress" ||
                     e.Column.Header.ToString() == "SecondaryTriggersBuildTaskValueType" ||
                     e.Column.Header.ToString() == "SecondaryTriggersBuildTaskValue" ||
                     e.Column.Header.ToString() == "SecondaryTriggersBuildTaskPoint" ||
                     e.Column.Header.ToString() == "TriggeredTaskTagDesc" ||
                     e.Column.Header.ToString() == "TriggeredTaskAddress" ||
                     e.Column.Header.ToString() == "TriggeredTaskValueType" ||
                     e.Column.Header.ToString() == "TriggeredTaskValue" ||
                     e.Column.Header.ToString() == "TagIsOn" ||
                     e.Column.Header.ToString() == "FirstTriggersTagIsOn" ||
                     e.Column.Header.ToString() == "SecondaryTriggersTagIsOn" ||
                     e.Column.Header.ToString() == "TaskDesc" ||
                     e.Column.Header.ToString() == "CreateTime" ||
                     e.Column.Header.ToString() == "CreateTimeText" ||
                     e.Column.Header.ToString() == "StartTime" ||
                     e.Column.Header.ToString() == "StartTimeText" ||
                     e.Column.Header.ToString() == "StartTimeText" ||
                     e.Column.Header.ToString() == "EndTime" ||
                     e.Column.Header.ToString() == "EndTimeText" ||
                     e.Column.Header.ToString() == "StartPoint" ||
                     e.Column.Header.ToString() == "EndPoint" ||
                     e.Column.Header.ToString() == "Status" ||
                     e.Column.Header.ToString() == "DataOrderNo" ||
                     e.Column.Header.ToString() == "IsDelete" ||
                     e.Column.Header.ToString() == "Point" ||
                     e.Column.Header.ToString() == "IsDelete" ||
                     e.Column.Header.ToString() == "IsTheTaskInProgressVisibility" ||
                     e.Column.Header.ToString() == "IsTheTaskNotPerformedVisibility" ||
                     e.Column.Header.ToString() == "FunctionSimulationVisibility" ||
                     e.Column.Header.ToString() == "IsDelete" ||
                     e.Column.Header.ToString() == "IsDeleteText"
               )
            {
                e.Cancel = true;
            }
        }

        private void DataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            e.Row.Header = e.Row.GetIndex() + 1;
        }
    }
}
